﻿using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace LinqBusinessObjectBuilder.Forms
{
    internal partial class GenerationCompleteForm : Form
    {
        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool MessageBeep(MessageBeepType type);

        public enum MessageBeepType
        {
            Default = -1,
            OK = 0x00000000,
            Error = 0x00000010,
            Question = 0x00000020,
            Warning = 0x00000030,
            Information = 0x00000040
        }

        private readonly string m_SolutionFilePath;
        private bool m_Beeped = false;

        public GenerationCompleteForm(string solutionFilePath)
        {
            InitializeComponent();

            m_SolutionFilePath = solutionFilePath;
        }

        private void btnOpenSolution_Click(object sender, EventArgs e)
        {
            Process.Start(m_SolutionFilePath);
        }

        private void btnOpenDirectory_Click(object sender, EventArgs e)
        {
            string directory = Path.GetDirectoryName(m_SolutionFilePath);
            Process.Start("explorer.exe", directory);
        }

        private void GenerationCompleteForm_Activated(object sender, EventArgs e)
        {
            if (!m_Beeped)
            {
                m_Beeped = true;
                MessageBeep(MessageBeepType.Information);
            }
        }
    }
}
